require("datastream")
local function OpenDupeBox(ply,cmd,args)
	local DupeBoxWindow = vgui.Create("DFrame")
	DupeBoxWindow:SetTitle("DupeBox")
	DupeBoxWindow:SetSize(ScrW() - 100, ScrH() - 100)
	DupeBoxWindow:Center()
	DupeBoxWindow:SetDeleteOnClose(false)
	DupeBoxWindow:MakePopup()
	local DupeBoxWeb = vgui.Create("HTML", DupeBoxWindow)
	DupeBoxWeb:SetPos(10, 50)
	DupeBoxWeb:SetSize(DupeBoxWindow:GetWide() - 20, DupeBoxWindow:GetTall() - 90)
	local Textbox = vgui.Create("DTextEntry", DupeBoxWindow)
	Textbox:SetText("http://www.dupebox.herobo.com/ingame/")
	Textbox:SetPos(10, 26)
	Textbox:SetSize(DupeBoxWindow:GetWide() - 20, 20)
	Textbox.OnEnter = function() DupeBoxWeb:OpenURL(Textbox:GetValue()) end
	DupeBoxWeb:OpenURL("http://www.dupebox.herobo.com/ingame/")
end
local function DupeBDownloadfile(contents,size)
	local temp = string.Explode("<!-- www.000webhost.com Analytics Code -->",contents)
	local filewrite = temp[1]
	local temp = string.Explode("|",filewrite)
	local name = temp[1]
	local data = table.concat(temp,"|",2)
	if (string.find(name,"<") or string.find(name,">")) then
		chat.AddText(Color(255,0,0),"Invalid DupeID!")
		chat.PlaySound()
		return "nothing"
	end
	datastream.StreamToServer("DupeBoxSend",{name,data})
	chat.AddText(Color(0,255,0),name.." Downloaded!")
	chat.PlaySound()
end
local function DownlDupeBox(ply,cmd,args)
	local sID = ply:SteamID()
	local cID = "7656"..tostring(tonumber(string.sub(sID, 11))*2 + 1197960265728 + tonumber(string.sub(sID, 9, 9)))
	http.Get("http://dupebox.herobo.com/ingame/download.php?id="..args[1].."&cid="..cID,"",DupeBDownloadfile)
	chat.AddText(Color(0,0,255),"Downloading...")
	chat.PlaySound()
end
concommand.Add("DupeBox_Show", OpenDupeBox)
concommand.Add("DupeBox_Download", DownlDupeBox)